/*
 * LocationCounter.h
 *
 *  Created on: May 5, 2012
 *      Author: omnia
 */

#ifndef LOCATIONCOUNTER_H_
#define LOCATIONCOUNTER_H_
#include <iostream>
#include <fstream>
#include <string>
#include<vector>
#include <ctype.h>
#include <utility>
#include <stdio.h>
#include <math.h>
#include <map>
#include "LabelObject.h"
#include "MyExpression.h"
#include "Line.h"
using namespace std;
using namespace __gnu_cxx;
namespace counter {

class LocationCounter {
public:
        //typedef map<string ,string> Table;
                //typedef hash_map<int ,string> errors;
                map<string ,LabelObject> symbolTable ;
                map<string ,int> litPool ;
                vector<Line*> output;
                vector<Line*> input;
                int locationCounter;

        LocationCounter(vector<Line*> lines);
         void add();
         void checkNotRefLabel();
         Line* checkLabel(Line *current,int lineNumber);
         Line* checkOperand(Line *current,int lineNumber);
         MyExpression evaluateExpression( string expr,int address);
         Line* checkOperation(Line *current);
         void printTable();
         void generateOutput();
         void checkLTORG();
         void writeFile();
         bool checkError(Line *curr);
         int calcLength(string literal);
         int calcValue(string operation);
        static int calcWordAndByte(string operation,bool EQU);

         virtual ~LocationCounter();
        //int main();
};

} /* namespace counter */
#endif /* LOCATIONCOUNTER_H_ */
